package com.cow.framework.utils.encrypt;

import java.security.MessageDigest;

import com.cow.framework.utils.string.Byte2HexStr;

/**
 * 
 * 计算MD5码
 * 
 * @author hehzh
 * @since 2014-10-14
 * @version 1.0
 *
 */
public class MD5Util {

	private MD5Util(){}

	/**
	 * 
	 * 计算字符串的MD5码
	 * 
	 * @param origin 需要计算MD5码的字符串
	 * @return 计算出的MD5码
	 *
	 */
	public static String crypt(String origin) {
		String resultString = null;
		try {
			resultString = new String(origin);
			MessageDigest md = MessageDigest.getInstance("MD5");
			resultString = Byte2HexStr.parse(md.digest(resultString.getBytes())).toLowerCase();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return resultString;
	}
	
//	public static void main(String[] args){
//		System.out.println(crypt("admintest"));		
//	}
}